
package controllers;
import vos.*;
import play.db.jpa.Transactional;
import play.libs.Json;
import sanduche.play.shared.SanController;
import play.mvc.Http.Request;
import play.mvc.Http.Response;
import play.mvc.Http.Session;
import play.mvc.Result;
import models.*;
public class CoordinadorController extends SanController {
	@Transactional
	public static Result getEstudiantes(String query){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getEstudiantes(session, query)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result goNext(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.goNext(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result newEstudiante(){
		try{
			Estudiante body = Json.fromJson(request().body().asJson(),Estudiante.class);
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.newEstudiante(session, body)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getGrados(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getGrados(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getCursosGrado(Long idGrado){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getCursosGrado(session, idGrado)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result newCurso(){
		try{
			Curso body = Json.fromJson(request().body().asJson(),Curso.class);
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.newCurso(session, body)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result deleteCurso(Long idCurso){
		try{
			Session session = session();
			sanduche.controllers.CoordinadorController.deleteCurso(session, idCurso);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getCurso(Long idCurso){
		try{
			
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getCurso(idCurso)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getMateriasCurso(Long idCurso){
		try{
			
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getMateriasCurso(idCurso)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getProfesores(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getProfesores(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getSecretarios(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getSecretarios(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result newProfesor(){
		try{
			Profesor body = Json.fromJson(request().body().asJson(),Profesor.class);
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.newProfesor(session, body)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result newSecretario(){
		try{
			Secretario body = Json.fromJson(request().body().asJson(),Secretario.class);
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.newSecretario(session, body)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result newOrientador(){
		try{
			Orientador body = Json.fromJson(request().body().asJson(),Orientador.class);
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.newOrientador(session, body)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result updateMateriaCurso(){
		try{
			MateriaCurso body = Json.fromJson(request().body().asJson(),MateriaCurso.class);
			sanduche.controllers.CoordinadorController.updateMateriaCurso(body);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result updateCurso(Long idCurso){
		try{
			Curso body = Json.fromJson(request().body().asJson(),Curso.class);
			sanduche.controllers.CoordinadorController.updateCurso(body, idCurso);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result newMatricula(){
		try{
			Matricula body = Json.fromJson(request().body().asJson(),Matricula.class);
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.newMatricula(session, body)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result updateEstudiante(Long idEstudiante){
		try{
			Estudiante body = Json.fromJson(request().body().asJson(),Estudiante.class);
			sanduche.controllers.CoordinadorController.updateEstudiante(body, idEstudiante);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result updatePersona(Long idPersona){
		try{
			Persona body = Json.fromJson(request().body().asJson(),Persona.class);
			sanduche.controllers.CoordinadorController.updatePersona(body, idPersona);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getMaterias(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getMaterias(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result getCalendarioAcademicoActual(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getCalendarioAcademicoActual(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result updateCalendarioAcademico(Long idCalendarioAcademico){
		try{
			CalendarioAcademico body = Json.fromJson(request().body().asJson(),CalendarioAcademico.class);
			Session session = session();
			sanduche.controllers.CoordinadorController.updateCalendarioAcademico(session, body, idCalendarioAcademico);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result getEstudiantesCurso(Long idCurso){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.CoordinadorController.getEstudiantesCurso(session, idCurso)));
		}catch(Throwable e){return parseError(e);}
	}
}